﻿using System.Xml.Linq;
using Engine;
using Game;
using GameEntitySystem;


public class DFWidget : CanvasWidget
{
    public ComponentPlayer m_componentPlayer;

    public SubsystemNK m_subsystemHL;

    public ComponentMiner componentMiner;

    public ButtonWidget m_DFButton;

    public GridPanelWidget m_inventoryGrid;

    public IInventory m_inventory;

    public SubsystemGameInfo m_subsystemGameInfo;
    public SubsystemTime subsystemTime;
    //下面是新人物状态按钮系统
    public DFWidget(ComponentPlayer componentPlayer, SubsystemNK subsystemHL)
    {
        m_componentPlayer = componentPlayer;
        m_subsystemHL = subsystemHL;





        //XElement node = ContentManager.Get<XElement>("Widgets/法性");
       // LoadContents(this, node);
       // m_DFButton = Children.Find<ButtonWidget>("DFButton");
    }

    public override void Update()
    {
        NK9 nk = m_componentPlayer.Entity.FindComponent<NK9>();
        ComponentSummoner componentSummoner = m_componentPlayer.Entity.FindComponent<ComponentSummoner>();
        int activeBlockValue = m_componentPlayer.ComponentMiner.ActiveBlockValue;
        int num = Terrain.ExtractContents(activeBlockValue);
        if (m_DFButton.IsClicked)
        {
            if (m_componentPlayer.PlayerData.Level >= 20f && m_subsystemHL.DF <= 0f)
            {
                m_subsystemHL.DF += 1f;
                Entity entity = DatabaseManager.CreateEntity(m_componentPlayer.Project, "小方块", throwIfNotFound: true);
                componentSummoner.Summon(entity, m_componentPlayer.ComponentBody.Position + new Vector3(0f, 1f, 0f));
            }
            else
            {
                m_componentPlayer.ComponentGui.DisplaySmallMessage("召唤失败，数量过多或是等级未到达20级", Color.White, blinking: true, playNotificationSound: false);
            }
        }
    }
}	

